<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./src/css/shoppingCart.css">
    <script src="./src/js/jquery.min.js"></script>
    <script src="./src/js/shoppingCart.js"></script>
</head>

<body>
    <!-- 登陆注/册导航/购物车 -->
    <div class="tl">
        <div class="info bx">
            <div class="txt fs14">正品保证,免息分期</div>
            <div class="infos">
                <ul class="fs14">
                    <li><a href="#">请登录</a></li>
                    <li><a href="#">注册即送3500元大礼包</a></li>
                    <li>|</li>
                    <li><a href="#">购物车</a></li>
                    <li><a href="#">客户服务</a></li>
                    <li><a href="#">会员福利</a></li>
                    <li>|</li>
                    <li><a href="#">ENGLISH</a></li>
                </ul>
            </div>
        </div>
    </div>
    <!-- show -->
    <div class="logo bx">
        <div class="logo_left">
            <img src="./src/image/shoppingCart/logo-icon.png" alt="">
            <img src="./src/image/shoppingCart/slogan-02242018.png" alt="">
        </div>
        <div class="logo_right">
            <div class="line"></div>
            <ol>
                <li class="current"></li>
                <li></li>
                <li></li>
                <li></li>
            </ol>
            <ul>
                <li>购物车</li>
                <li>填写订单信息</li>
                <li>支付订单</li>
                <li>等待签收</li>
            </ul>
        </div>
    </div>
    <!-- show -->
    <div class="bx allShop">全部商品<span></span></div>
    <table class="bx tab1">
        <thead>
            <tr>
                <td>
                    <input type="checkbox" id="all">
                </td>
                <td>
                    全选
                </td>
                <td>
                    商品信息
                </td>
                <td>
                    单价
                </td>
                <td>
                    数量
                </td>
                <td>
                    小计
                </td>
                <td>
                    操作
                </td>
            </tr>
        </thead>
        <tbody>
            <tr class="tbody_line"></tr>
            <tr class="tbody_line1">
                <td>
                    <input type="checkbox">
                </td>
                <td colspan="5" style="text-align: left;">
                    欧米茄OMEGA
                </td>
                <td>
                    <div class="lingjuan">
                        领劵
                    </div>
                </td>
            </tr>
            <tr class="tbody_line2">
                <td></td>
                <td>
                    满减&nbsp;&nbsp;每满500减80元,上不封顶!
                </td>
                <td colspan="5">
                </td>
            </tr>
            <tr class="tbody_line3">

            </tr>
        </tbody>
        <table class="bx tab2">
            <thead>
                <tr>
                    <td>
                        <input type="checkbox" id="all2">
                    </td>
                    <td>
                        全选
                    </td>
                    <td>
                        删除
                    </td>
                    <td>
                        移入收藏
                    </td>
                    <td>
                        清空失效商品
                    </td>
                    <td>
                        已选商品
                    </td>
                    <td style="height: 80px;">
                        合计<span style="color: red;">¥<span id="heji">0</span></span>
                    </td>
                    <td id="buyAll" style="background-color: red;text-align: center;color: white;">
                        结算
                    </td>
                </tr>
            </thead>
        </table>
    </table>


    <!-- 底部 -->
    <footer>
        <img src="./src/image/fotter.jpg" alt="">
    </footer>
</body>

</html>
<script>
    $('#buyAll').on('click', function () {
        let uid = JSON.parse(localStorage.getItem('user') || '{}').u_id;
        console.log(uid);
        let cartList = JSON.parse(localStorage.getItem('cart') || "{}");
        cartList.u_id = uid;
        let saveObj = { ...cartList }
        delete (saveObj.p_imgs)
        console.log(saveObj);

        $.ajax({
            type: 'post',
            url: 'api/addCart',
            data: saveObj,
            success(res) {
                console.log(res);
            }
        })
    })

</script>